/*
Binary clock
By: DanielQB
v0.11
*/

#include <Time.h>

int i,j;

#define num_cols 5
int col[num_cols] = {42,40,38,32,22};  //Arreglo de columnas

#define num_rows 4
int row[num_rows] = {30,28,26,24};  //Arreglo de filas

int T[6];

void setup(){
  setTime(1305194711);

  for(int i=0; i < num_rows; i++){
    pinMode(row[i], OUTPUT);
    digitalWrite(row[i], LOW);
  }
  for(int j=0; j < num_cols; j++){
    pinMode(col[j], OUTPUT);
    digitalWrite(col[j], HIGH);
  }
}

void loop(){
  T[0]=hour()/10;
  T[1]=hour()%10;
  T[2]=minute()/10;
  T[3]=minute()%10;
  T[4]=second()/10;
  T[5]=second()%10;
  
  for(i=0;i<6;i++){
    digitalWrite(col[i], LOW);
    for(j=0;j<4;j++){
      if(bitRead(T[i], j)==1)
        digitalWrite(row[j], HIGH);
    }
//    delay(10);
    
    digitalWrite(col[i], HIGH);
    digitalWrite(row[0], LOW);
    digitalWrite(row[1], LOW);
    digitalWrite(row[2], LOW);
    digitalWrite(row[3], LOW);
  }
}
